package org.langqiao.thread;

public class MyThread extends Thread{
	private int count = 5;
	
	public void run(){
		count --;
		System.out.println(this.currentThread().getName()+" count= " + count);
	}
	
	public static void main(String[] args) {
		/**
		 * 多个线程访问myThread的run方法时，以排队方式进行处理，这里的排队是按照cpu分配的先后顺序而定的
		 */ 
		MyThread myThread = new MyThread();
		Thread t1 = new Thread(myThread, "t1");
		Thread t2 = new Thread(myThread, "t2");
		Thread t3 = new Thread(myThread, "t3");
		Thread t4 = new Thread(myThread, "t4");
		Thread t5 = new Thread(myThread, "t5");
		t1.start();
		t2.start();
		t3.start();
		t4.start();
		t5.start();
	}
}
